package ro.prjmanager.core.context;


import ro.prjmanager.core.usr.UserSession;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Locale;

/**
 * WebContextFactoryImpl.java Copyright (c) 2009 Teamnet. All Rights Reserved. This source file may
 * not be copied, modified or redistributed, in whole or in part, in any form or for any reason,
 * without the express written consent of Teamnet.
 */
@SuppressWarnings({"ALL"})
public class WebContextFactoryImpl<U,P,S,D,SC> implements WebContext<U,P,S,D,SC>{

    private HttpServletRequest request;
    private HttpServletResponse response;

    public WebContextFactoryImpl(HttpServletRequest request, HttpServletResponse response) {
        this.request = request;
        this.response = response;
    }

    public HttpSession getSession() {
         return this.request.getSession();
    }

    public HttpSession getSession(boolean create) {
         return  this.request.getSession(create);
    }

    public HttpServletRequest getRequest() {
        return this.request;
    }

    public HttpServletResponse getResponse() {
        return this.response;
    }

    public Locale getLocale() {
        return this.request.getLocale();
    }

    public UserSession<U,P,S,D,SC> getUserSession() {
        return (UserSession<U,P,S,D,SC>) this.request.getSession().getAttribute(SecurityContext.USER_KEY);
    }
}
